package com.yanqu.road.entity.activity.operamask;

import com.yanqu.road.entity.activity.ActivityConfig;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.operamask.config.OperaMaskSceneConfig;
import com.yanqu.road.entity.activity.operamask.config.OperaMaskSingConfig;
import com.yanqu.road.entity.activity.operamask.config.OperaMaskSkillConfig;
import com.yanqu.road.utils.string.StringUtils;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class OperaMaskConfig {

    private ActivityInfo activityInfo;

    private int energyItemId;
    private int jinGuaZiItemId;
    private int scoreItemId;                                                // 兑换商店积分道具（排行榜的积分是雅韵值）
    private int randomSkillItemId;

    private Map<Integer, OperaMaskSceneConfig> sceneConfigMap;              // 关卡ID，关卡配置
    private Map<Integer, List<OperaMaskSkillConfig>> skillConfigMap;        // 技能ID，技能各个等级的配置

    private List<Integer> blockWeightList;
    private int blockBaseWeight;
    private int colorNum;

    private int maxEnergy;

    private List<Integer> skipCostEnergyList;

    private Map<Integer, OperaMaskSingConfig> singConfigMap;

    private List<Integer> paintBoxUnlockList;

    private int guideSkillId;

    private int randomExistSkillPercent;
    private int randomExistSkillStep;

    private int tokenYaYun;

    /**
     * 初始化配置
     */
    public void initActivityConfig(Map<String, ActivityConfig> activityConfigMap) {
        setBlockWeightList(activityConfigMap.get("OPERA_CREATE_BLOCK_WEIGHT_LIST").getIntListValue(";"));
        setBlockBaseWeight(activityConfigMap.get("OPERA_CREATE_BLOCK_WEIGHT_NUM").getIntValue());
        setColorNum(activityConfigMap.get("OPERA_CREATE_BLOCK_COLOR_NUM").getIntValue());
        setEnergyItemId(activityConfigMap.get("OPERA_ENERGY_ITEM_ID").getIntValue());
        setJinGuaZiItemId(activityConfigMap.get("OPERA_SEED_ITEM_ID").getIntValue());
        setScoreItemId(activityConfigMap.get("EXCHANGE_SCORE_ITEM_ID").getIntValue());
        setMaxEnergy(activityConfigMap.get("OPERA_ENERGY").getIntValue());
        // setSkipCostEnergyList(activityConfigMap.get("OPERA_SKIP_ENERGY_COST").getIntListValue("\\|"));
        List<String> singLevelList = StringUtils.stringToStringList(activityConfigMap.get("OPERA_LEVEL_COST").getValue(), "\\|");
        Map<Integer, OperaMaskSingConfig> tempSingConfigMap = new ConcurrentHashMap<>();
        for (int level = 1; level <= singLevelList.size(); level++) {
            String[] split = singLevelList.get(level - 1).split("=");
            tempSingConfigMap.put(level, new OperaMaskSingConfig(level, Integer.valueOf(split[1]), Integer.valueOf(split[0])));
        }
        setSingConfigMap(tempSingConfigMap);
        setPaintBoxUnlockList(activityConfigMap.get("OPERA_PAINT_BOX_UNLOCK").getIntListValue("\\|"));
        setGuideSkillId(activityConfigMap.get("OPERA_GUIDE_SKILL").getIntValue());
        setRandomSkillItemId(activityConfigMap.get("OPERA_ROLL_ITEM_ID").getIntValue());
        List<Integer> randomExistSkillList = activityConfigMap.get("OPERA_ROLL_GUARANTEED").getIntListValue("\\|");
        setRandomExistSkillStep(randomExistSkillList.get(0));
        setRandomExistSkillPercent(randomExistSkillList.get(1));

        ActivityConfig tokenYayun = activityConfigMap.get("OPERA_TOKEN_YAYUN");
        tokenYaYun = tokenYayun != null ? tokenYayun.getIntValue() : 0;
    }

    // ===================

    public void setActivityInfo(ActivityInfo activityInfo) {
        this.activityInfo = activityInfo;
    }

    public void setEnergyItemId(int energyItemId) {
        this.energyItemId = energyItemId;
    }

    public void setJinGuaZiItemId(int jinGuaZiItemId) {
        this.jinGuaZiItemId = jinGuaZiItemId;
    }

    public void setScoreItemId(int scoreItemId) {
        this.scoreItemId = scoreItemId;
    }

    public void setSceneConfigMap(Map<Integer, OperaMaskSceneConfig> sceneConfigMap) {
        this.sceneConfigMap = sceneConfigMap;
    }

    public void setSkillConfigMap(Map<Integer, List<OperaMaskSkillConfig>> skillConfigMap) {
        this.skillConfigMap = skillConfigMap;
    }

    public void setBlockWeightList(List<Integer> blockWeightList) {
        this.blockWeightList = blockWeightList;
    }

    public void setBlockBaseWeight(int blockBaseWeight) {
        this.blockBaseWeight = blockBaseWeight;
    }

    public void setColorNum(int colorNum) {
        this.colorNum = colorNum;
    }

    public void setMaxEnergy(int maxEnergy) {
        this.maxEnergy = maxEnergy;
    }

    public void setSkipCostEnergyList(List<Integer> skipCostEnergyList) {
        this.skipCostEnergyList = skipCostEnergyList;
    }

    public void setSingConfigMap(Map<Integer, OperaMaskSingConfig> singConfigMap) {
        this.singConfigMap = singConfigMap;
    }

    public void setPaintBoxUnlockList(List<Integer> paintBoxUnlockList) {
        this.paintBoxUnlockList = paintBoxUnlockList;
    }

    // ===================

    public ActivityInfo getActivityInfo() {
        return activityInfo;
    }

    public int getEnergyItemId() {
        return energyItemId;
    }

    public int getJinGuaZiItemId() {
        return jinGuaZiItemId;
    }

    public int getScoreItemId() {
        return scoreItemId;
    }

    public Map<Integer, OperaMaskSceneConfig> getSceneConfigMap() {
        return sceneConfigMap;
    }

    public Map<Integer, List<OperaMaskSkillConfig>> getSkillConfigMap() {
        return skillConfigMap;
    }

    public List<Integer> getBlockWeightList() {
        return blockWeightList;
    }

    public int getBlockBaseWeight() {
        return blockBaseWeight;
    }

    public int getColorNum() {
        return colorNum;
    }

    public int getMaxEnergy() {
        return maxEnergy;
    }

    public List<Integer> getSkipCostEnergyList() {
        return skipCostEnergyList;
    }

    public Map<Integer, OperaMaskSingConfig> getSingConfigMap() {
        return singConfigMap;
    }

    public List<Integer> getPaintBoxUnlockList() {
        return paintBoxUnlockList;
    }

    public int getGuideSkillId() {
        return guideSkillId;
    }

    public void setGuideSkillId(int guideSkillId) {
        this.guideSkillId = guideSkillId;
    }

    public int getRandomExistSkillPercent() {
        return randomExistSkillPercent;
    }

    public void setRandomExistSkillPercent(int randomExistSkillPercent) {
        this.randomExistSkillPercent = randomExistSkillPercent;
    }

    public int getRandomSkillItemId() {
        return randomSkillItemId;
    }

    public void setRandomSkillItemId(int randomSkillItemId) {
        this.randomSkillItemId = randomSkillItemId;
    }

    public int getRandomExistSkillStep() {
        return randomExistSkillStep;
    }

    public void setRandomExistSkillStep(int randomExistSkillStep) {
        this.randomExistSkillStep = randomExistSkillStep;
    }

    public int getTokenYaYun() {
        return tokenYaYun;
    }

    public void setTokenYaYun(int tokenYaYun) {
        this.tokenYaYun = tokenYaYun;
    }
}
